package com.campus.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.campus.commons.entity.Departments;
import com.campus.app.mapper.DepartmentsMapper;
import com.campus.app.service.DepartmentssService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.campus.commons.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 部门表 服务实现类
 * </p>
 *
 * @author Rin
 * @since 2020-12-24
 */
@Service
public class DepartmentsServiceImpl extends ServiceImpl<DepartmentsMapper, Departments> implements DepartmentssService {
    @Autowired
    private DepartmentsMapper departmentsMapper;

    @Override
    public Result<Departments> getDepartmentById(Integer id) {
        return Result.verify(getById(id));
    }

    @Override
    public Boolean exists(int fileId) {
        QueryWrapper<Departments> wrapper = new QueryWrapper<>();
        wrapper.eq("fileId", fileId);
        Integer integer = departmentsMapper.selectCount(wrapper);
        return integer==1?true:false;
    }
}
